<template>
  <div class="box" id="jungongcehuiResultFuShenZHJGXX">
    <div v-if="flag==1">
      <div class="display_flex box_search">
        <div class="display_flex margin_rignt">
          <p>权利人姓名：</p>
          <div>
            <el-input v-model="needInfo.applicantName" placeholder="请输入"></el-input>
          </div>
        </div>
        <div class="display_flex margin_rignt">
          <p>复垦片块：</p>
          <div>
            <el-select clearable v-model="needInfo.landId" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </div>
        </div>
        <div class="display_flex margin_rignt">
          <p>开始时间：</p>
          <div>
            <el-date-picker
              value-format="yyyy-MM-dd"
              v-model="needInfo.startTime"
              type="date"
              placeholder="选择日期"
            ></el-date-picker>
          </div>
        </div>
        <div class="display_flex margin_rignt">
          <p>截止时间：</p>
          <div>
            <el-date-picker
              value-format="yyyy-MM-dd"
              v-model="needInfo.finishTime"
              type="date"
              placeholder="选择日期"
            ></el-date-picker>
          </div>
        </div>
        <el-button @click="search" type="primary">查询</el-button>
      </div>
      <div class="table">
        <el-table v-loading="listLoading" :data="tableData" border style="width: 100%">
          <el-table-column type="index" show-overflow-tooltip label="序号" width="80" align="center"></el-table-column>
          <el-table-column prop="applyNum" label="申请编号" align="center"></el-table-column>
          <el-table-column prop="applicantName" label="权利人" align="center"></el-table-column>
          <el-table-column prop="landName" label="外业核查地块" align="center"></el-table-column>
          <el-table-column prop="villageName" label="核查位置" align="center"></el-table-column>
          <el-table-column prop="count" label="外业核查时间" align="center"></el-table-column>
          <!-- <el-table-column prop="date" label="抽查结果"></el-table-column> -->

          <el-table-column label="操作" fixed="right">
            <!--  <template slot-scope="scope"> -->
            <template slot-scope="scope">
              <el-button size="mini" type="primary" @click="lookItem(scope.row)">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="pages">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10, 15, 20, 25]"
          :page-size="needInfo.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </div>
    <div class="landInfo" v-if="flag==2">
      <div class="back">
        <el-button icon="el-icon-back" size="small" @click="flag=1">返回</el-button>
      </div>
      <div class="title">
        <p class="title_one">{{itemDetail.landName}}</p>
        <p class="title_little">
          <span>核查时间：{{itemDetail.landName}}</span>
          <span>核查人：{{itemDetail.applicantName}}</span>
          <span>核查位置：{{itemDetail.villageName}}</span>
        </p>
      </div>
      <!-- <div class="project_position">
        <div class="project_title">
          外业核查意见
        </div>
        <div class="project_result">
            <div class="display_flex">
                <el-checkbox v-model="checked" disabled>复垦点坐标是否准确，位置是否准确</el-checkbox>
            </div>
            <div class="display_flex">
                <el-checkbox v-model="checked" disabled>复垦点1:500测绘范围内外地形、地貌、地类与实地是否一致</el-checkbox>
            </div>
            <div class="display_flex">
                <el-checkbox v-model="checked" disabled>范围是否与现场一致</el-checkbox>
            </div>
            <div class="display_flex">
                <el-checkbox v-model="checked" disabled>远近景照片是否真实反映复垦点情况</el-checkbox>
            </div>
            <div class="display_flex">
                <el-checkbox v-model="checked" disabled>抽查复垦点权利人姓名与图中标注的是否一致</el-checkbox>
            </div>
            <div class="display_flex">
                <el-checkbox v-model="checked" disabled>复垦点地类是否综合过大，是否把与外围集中连片的耕地、林地、园地等纳入复垦范围</el-checkbox>
            </div>
          
        </div>
      </div>-->
      <div class="project_position">
        <div class="project_title">施工自验现场位置及轨迹</div>
        <div class="project_img">
          <!-- <img src="../../../assets/mapText.png" width="500" height="400" /> -->
          <tdMap style="height: 600px" class="mapBox_right" ref="tdMap" :pkList="mainDataData" :isShowControls="false" />
        </div>
      </div>
      <div class="project_position">
        <div class="project_title">外业核查资料</div>
        <div class="project_img">
          <el-table :data="list" border style="width: 100%">
            <el-table-column type="index" show-overflow-tooltip label="序号" width="60"></el-table-column>
            <el-table-column prop="name" label="类型" width="200"></el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button size="mini" type="primary" fixed="left" @click="btnSeeImg(scope.row)">查看</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>

    <el-dialog :title="title" :before-close="handleClose" :visible.sync="seeImgDialog" width="50%">
      <div class="imgBox" style="width:500px;height:500px;margin:0 auto;" v-if="showImgType==1">
        <img style="width:100%;height:100%;" :src="$https+path" alt />
      </div>
      <div class="imgBox" style="width:700px;height:400px;margin:0 auto;" v-if="showImgType==2">
        <video id="showVedio" autoplay controls style="width:100%;height:100%;" :src="$https+path"></video>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { supervisingInfo1, jgfsZhkgxx } from "@/api/jungongcehuiResultFuShen";
import { getLandStatusMapAuditInfo } from "@/api/jjgc";
import tdMap from "@/components/tdMap";
export default {
  components: {
    tdMap
  },
  data() {
    return {
      checked: true,
      flag: 1,
      options: [],
      value: "",
      tableData: [],
      currentPage4: 1,
      title: "",
      path: "",
      showImgType: 1,
      seeImgDialog: false,
      list: [],
      needInfo: {
        page: 1,
        size: 10,
        projectId: localStorage.getItem("projectId"),
        landId: "",
        applicantName: "",
        startTime: "",
        finishTime: ""
      },
      total: 0,
      listLoading: false,
      itemDetail: null, //单条数据（用于详情）
      mainDataData:[],
    };
  },
  created() {
    this.getData();
    this.getDataSelect();
  },
  methods: {
    //关闭弹框
    handleClose() {
      this.seeImgDialog = false;
      if (this.showImgType == 2) {
        var vedio = document.getElementById("showVedio");
        vedio.currentTime = 0;
        vedio.pause();
      }
    },
    //查看单条详情
    lookItem(row) {
      console.log(row,'rrr');
      this.itemDetail = row;
      var data1={
        landId:row.landId,
      }
      getLandStatusMapAuditInfo(data1).then(res=>{
        let obj=res.data
        let array=[]
        array.push(obj)
        this.mainDataData=array
      })
      var data = {
        page: 1,
        size: 2,
        photo: row.photo ? row.photo : "",
        vcr: row.vcr ? row.vcr : ""
      };

      jgfsZhkgxx(data).then(res => {
        console.log(res);
        var imageGeShi = ["bmp", "pcx", "png", "jpg", "jpeg", "gif", "tiff"];
        var videoGeShi = [
          "mp4",
          "avi",
          "flv",
          "rmvb",
          "mkv",
          "gif",
          "mov",
          "rm",
          "3gp"
        ];
        var mainList = [];
        var mainList1 = [];
        res.data.rows.forEach((item, index) => {
          imageGeShi.forEach(item1 => {
            if (
              item.fileKey.substring(
                item.fileKey.indexOf(".") + 1,
                item.fileKey.length
              ) == item1
            ) {
              mainList.push({
                name: "外业核查照片",
                path: item.filePath,
                type: 1
              });
            }
          });
        });
        res.data.rows.forEach((item, index) => {
          videoGeShi.forEach(item1 => {
            if (
              item.fileKey.substring(
                item.fileKey.indexOf(".") + 1,
                item.fileKey.length
              ) == item1
            ) {
              mainList1.push({
                name: "核查现场视频",
                path: item.filePath,
                type: 2
              });
            }
          });
        });
        //名称处理
        mainList.forEach((item, index) => {
          item.name = item.name + (index != 0 ? index : "");
        });
        mainList1.forEach((item, index) => {
          item.name = item.name + (index != 0 ? index : "");
        });
        this.list = mainList.concat(mainList1);

        this.flag = 2;
      });
    },
    //搜索
    search() {
      this.getData();
    },
    getData() {
      this.listLoading = true;
      var data = this.needInfo;
      supervisingInfo1(data)
        .then(res => {
          this.listLoading = false;
          console.log(res, "真实数据");
          this.tableData = res.data.rows;
          this.total = res.data.total;
        })
        .catch(error => {
          this.listLoading = false;
        });
    },
    getDataSelect() {
      var data = {
        projectId: localStorage.getItem("projectId"),
        page: 1,
        size: 99999
      };
      supervisingInfo1(data).then(res => {
        console.log(res, "选择框");
        var arr = [];
        if (res.data.rows != null && res.data.rows.length != 0) {
          res.data.rows.forEach(item => {
            arr.push({ value: item.landId, label: item.landName });
          });
        }
        this.options = arr;
      });
    },
    btnSeeImg(row) {
      console.log(row);
      this.title = row.name;
      this.path = row.path;
      this.showImgType = row.type;
      this.seeImgDialog = true;
      if (row.type == 2) {
        var vedio = document.getElementById("showVedio");
        vedio.play();
      }
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.needInfo.size = val;
      this.getData();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.needInfo.page = val;
      this.getData();
    }
  }
};
</script>

<style scoped>
#jungongcehuiResultFuShenZHJGXX
  >>> .el-checkbox__input.is-disabled
  + span.el-checkbox__label {
  border-color: #409eff;
}
#jungongcehuiResultFuShenZHJGXX
  >>> .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner {
  border-color: #409eff;
  background-color: #409eff;
}
#jungongcehuiResultFuShenZHJGXX
  >>> .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner::after {
  border-color: #fff;
}
#jungongcehuiResultFuShenZHJGXX
  >>> .el-checkbox__input.is-disabled
  + span.el-checkbox__label {
  color: #12203e;
}
.box {
  padding: 30px;
}
.display_flex {
  display: flex;
  align-items: center;
}
.box_search .display_flex p {
  font-size: 14px;
  color: #333333;
}
.margin_rignt {
  margin-right: 30px;
}
.table {
  margin: 20px 0px;
}

.landInfo {
  border: 1px solid #efefef;
  box-sizing: border-box;
}
.back {
  margin: 20px;
}
.title_one {
  text-align: center;
  line-height: 40px;
  font-size: 20px;
  color: #444;
  font-weight: bold;
}
.title_little {
  font-size: 13px;
  color: #999;
  margin: 40px 20px 20px 30px;
}
.title .title_little span {
  margin-right: 30px;
}
.project_title {
  background: #f8f8f8;
  height: 50px;
  background: #f8f8f8;
  padding: 0px 30px;
  line-height: 50px;
  color: #48494d;
  font-size: 14px;
  font-weight: bold;
  border-top: 1px solid #efefef;
  border-bottom: 1px solid #efefef;
}
.project_img {
  padding: 30px;
}
.seeImg {
  text-align: center;
}
.project_result {
  padding: 30px;
}
.project_result .display_flex {
  margin-bottom: 20px;
  font-size: 13px;
  color: #444;
  width: 180px;
}
.pages {
  text-align: center;
}
.mapBox_right{
  width: 600px;
  height: 600px;
  margin-top:30px; 
}
</style>